package com.hanliukui.ai.langchain4j.assistant.xiaozhi;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

import java.util.Date;

@RestController
@RequestMapping("/xiaozhi")
public class XiaoziAiController {

    @Autowired
    private XiaoziChatAssistant xiaoziChatAssistant;

    @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
    public Flux<String> chat(@RequestBody ChatForm chatForm) {
        String sessionId = chatForm.getMemoryId();
        String message = chatForm.getMessage();
        String memoryId = "GGXZ-" + sessionId;
        return xiaoziChatAssistant.chat(memoryId, message, new Date());
    }
}
